package org.wheel.plugins.toolkit.sql.core;

import org.wheel.plugins.toolkit.sql.helper.AliasRegistry;
import org.wheel.plugins.toolkit.sql.helper.ParamBank;

/**
 * 每个 Wrapper 实例独立的上下文，隔离 AliasRegistry 和 ParamBank
 */
public final class WrapperContext {

    private final AliasRegistry aliasRegistry = new AliasRegistry();
    private ParamBank paramBank = new ParamBank();

    public WrapperContext() {
//        this.paramBank = ParamBank.openBranch(); // 新建独立分支
        this.paramBank.openBranch();
    }

    public AliasRegistry getAliasRegistry() {
        return aliasRegistry;
    }

    public ParamBank getParamBank() {
        return this.paramBank;
    }

    public void setParamBank(ParamBank paramBank){
        this.paramBank = paramBank;
    }

    public void close() {
        this.getParamBank().root(); // 弹出当前分支，避免堆积
    }
}